import {
  createHashHistory,
  createBrowserHistory,
  createMemoryHistory,
  MemoryHistoryBuildOptions,
  BrowserHistoryBuildOptions,
  HashHistoryBuildOptions,
} from 'history';

export interface ICreateHistoryOptions {
  type: 'hash' | 'browser' | 'memory';
  options?: HashHistoryBuildOptions | BrowserHistoryBuildOptions | MemoryHistoryBuildOptions;
}

export default function createHistory({ type, options }: ICreateHistoryOptions) {
  switch (type) {
    case 'browser':
      return createBrowserHistory(options);
    case 'memory':
      return createMemoryHistory(options);
    default:
      return createHashHistory(options);
  }
}
